use autosite::grap_site::{make_spider_callbox, SpiderConfig};
use common::compose::make_empty_ctx;
use log::info;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // 初始化日志系统
    env_logger::init();

    // 创建爬虫配置
    let config = SpiderConfig {
        base_url: "https://cisco.github.io/ChezScheme/csug/".to_string(),
        output_dir: "output/html".to_string(),
        depth: 2,
        page_limit: 50,
        subdomains: true,
        delay: 100,
        timeout: 30,
        verbose: true,
    };

    info!("开始爬取网站: {}", config.base_url);

    // 创建爬虫 CallBox
    let spider_callbox = make_spider_callbox(config);

    // 执行爬取
    let results = spider_callbox.run((), make_empty_ctx()).await?;

    info!("爬取完成，共爬取到 {} 个页面", results.len());

    Ok(())
}
